To realize the accurate indication of the over-the-horizon target by UAVs in an uncertain environment with movement and static obstacles, a cooperative control algorithm is proposed for two UAVs based on optimization of observation, to increase measurement information and reduce the uncertainty of target state estimation. The cooperative control algorithm is designed to obtain optimized tracking of UAVs and enhance the ability of cooperative estimation to the target position according to the index function of optimal observation by two UAVs in three-dimensional space which is deduced theoretically based on the Fisher information matrix (FIM) that represents obtained information of the target. A collision avoidance strategy is proposed to keep optimization of observation based on the relative velocity space with considering the limitations of the turning angle rate and the sensor detection distance, and the obstacle avoidance control algorithm is designed to avoid static and moving obstacles. Simulation experiments verify the effectiveness and practicability of the proposed control method. The simulation results show that the control algorithm can guide the UAV to the optimal observation position, and at the same time complete the avoidance of moving and stationary obstacles.