Hi I think they are legally able to do this from my understanding of EU law. It sucks especially if you have had to relocate for the job but you obviously were not enjoying working for them. It sounds as if the lead dev might be feeling overprotective of his own work and does not want to let go. I am sure you will find another job easily enough as good devs are in demand. Hopefully at a place where you are valued and…
Not being a good fit won't be good enough. If it was, the minimum period in a contract wouldn't be worth anything as that's easy for an employer to say with no backup.
This issue is a major difference between typical contracts in the EU and the at will employment status which is typical in the US. It makes it 'easier' for startups to operate in the US, and means that international companies will hire slower in the EU, but are more likely to let US staff go if they have to change staffing levels quickly.
Depending on the rental contract - if it's anything like the UK, the author may have a cause of action against the landlord as well - normally there's a minimum notice period.