Apollo 8 and 10 both went to the moon without landing, doing that on a multiple year mission does seem wasteful. However, there are a host of things to test.
From an engineering perspective going to mars orbit means far less sunlight which means a host of new problems. An engine and fuel system to get there would be new and could also be used to send a lander for future missions.
IMO, the Moon might be closer, but Mars is a much better target for long term colonization due to an atmosphere, shorter day, higher gravity, etc.