This is a bit convoluted as there isn't an easy to read government page that explicitly spells this out. Instead there are various websites which point out the legalities by going around the houses. I think when applying for the visa its covered somewhere.
I think this website covers it best.
Once the person is inside the UK or at a port of entry, they must meet the legal definition of a refugee. The Immigration Rules point us to the relevant international treaty which is the Convention Relating to the Status of Refugees done at Geneva on 28 July 1951 and the New York Protocol of 31 January 1967 (often just referred to as the “Refugee Convention” or the “Geneva Convention”). A refugee is defined in Article 1A of the Refugee Convention as a person who
owing to a well-founded fear of being persecuted for reasons of race, religion, nationality, membership of a particular social group or political opinion, is outside the country of his nationality and is unable, or owing to such fear, is unwilling to avail himself of the protection of that country; or who, not having a nationality and being outside the country of his former habitual residence as a result of such events, is unable or, owing to such fear, is unwilling to return to it.
And
the Immigration Rules at paragraph 339A(i) say explicitly that a refugee who voluntarily re-avails themselves of the protection of their country of origin can face revocation of refugee status. The same rule does not exist for humanitarian protection — yet the Home Office appears to apply that same standard when it comes to settlement applications.
freemovement.org.uk/what-is-the-difference-between-refugee-status-and-humanitarian-protection/
So to take refugee status you have to meet certain criteria. The homes for ukraine visa, allows Ukrainians to bypass the asylum seeker process and give them automatic refugee status (and therefore the right to work immediately) but it is categorically a refugee visa not a work visa. As such you have to meet the legal definition of a refugee. That does mean you can't just go back to your home country because you feel like it and then return to the uk and expect to retain your refugee status. Return home does invalidate it because it demonstrates you feel it is safe enough to do.
The time limit is to stop Ukrainians being able to automatically have a path to indefinite leave to remain which refugees have the right to after 5 years. Hence the 3 year limit. The plan is that Ukrainian refugees are only here temporarily. The government have been explicit about this. Some will be able to extend their stay through application for other visas but the majority they want to eventually go home.
The three year cut off is going to become a political hot potato at some point im sure. What happens to all these Ukrainians who want to stay? Indefinite leave to remain is also a costly visa to apply for. I'd argue that its impossible to get if you are on minimum wage if you are living independently due to the fees involved. So only certain minimum wage jobs are going to be open for visas: think care home staff if an employer is prepared to foot the bill for the work visa. Realistically its going to be a route for professionals only.
The way the government have done the visa is strategic. Its based on the belief the war will not be as long as 3 years and that Ukrainians are here temporarily. Again if that changes there's going to be an issue. Especially if a large percentage of those on Ukraine visas are simply claiming UC. Its going to be a political issue that the right will play to.
It leaves the home office with options to use to forceably remove Ukrainians at a later date if they wish to.