"Having a pet is legal."
Translation:Το να έχεις ένα κατοικίδιο είναι νόμιμο.
As you may know, Modern Greek doesn't have an infinitive that works the way that (say) an English infinitive does, so you have to use a personal form.
If you don't have a particular person in mind but are speaking generally, then as in English, often the second person singular is used (the way I did at the beginning of this paragraph -- "if you don't" wasn't speaking specifically to you, anna8691, but speaking about what people do in general).
Thus this has «το να έχεις» "the [fact] that you have...", with generic "you".
If a specific person is intended, you can also use that instead of the generic "you", e.g. «το να έχουμε ένα κατοικίδιο είναι νόμιμο» for "it's legal for us to have a pet".
Or, as in English, you can use the unspecific "one" -- το να έχει κανείς είναι νόμιμο "it's legal for one to have a pet". This uses the pronoun κανείς "one; someone" and the third person singular form of the verb.