A 5 year old and a 1 year old can share a room.
However when a 5 year old and a 1 year old share a room it can lead to sleep disruptions for the 5 year old if the 1 year old doesn't sleep too good through the night or wakes up crying etc.
If possible it's best to wait until the 1 year old is at least 2.5 to 3 years old before they share a room with an older sibling to avoid sleep disruptions.
But sometimes there's no other choice if you have no other room.
If possible it's best to have the 1 year old sleep in the same room as the parents and allow the 5 year old to have a room to themselves or with a similar aged sibling or older sibling to avoid sleep disruptions.
I used to share a room with my 1 year old brother when I was 5 and he would wake me up through the night by crying and not sleeping fully himself.
I would sometimes at 5 go out to the living room and sleep on the couch to get away from the crying.
However if the 1 year old is a good sleeper then it can be okay for the 5 year old to share a room with the 1 year old.
Sometimes you have to do what you have to do.
In the old days even whole families shared the same room or just a one room house.