1. They looked like they WERE having a wonderful time.
2. They looked to be having a wonderful time.
They have about the same meaning, but (1) sounds more colloquial. it is what most people say in daily situations.
(2) sounds a bit formal and serious, and "They appeared/seemed to be..." is more common than "looked to be", although "looked to be" is certainly not wrong.
There are also these related structures:
- It looked like they were having a wonderful time.
- It appeared that/like they were having a wonderful time.
- It seemed that/like they were having a wonderful time.
All these sentences mean more or less the same thing, with only a very small difference in nuance.