Wellbore trajectory optimization without instability well problems represents the most crucial factor in wells drilling planning and design today. Consequently, this article describes a method for designing and optimizing directional and horizontal well trajectories based on PSO algorithm technique of numerical optimization. The primary purpose of this article is to describe and optimum well trajectory design that at the lowest cost can hit the target objective. The design model relates to an actual well trajectory that has been drilled reference to a field geological data. The selected trajectories are S-type profile and double build horizontal trajectory based on field data analysis. The S-type profile has been design using explicit calculations and the double build horizontal trajectory has been design and optimize using numerical optimization technique (PSO algorithm). This article describes the background theory and wellbore stability models used to develop the study models. A side-tracking well (Well-3) of total vertical depth 10729 ft is drilled in order to reach two targets: Upper and Lower Bahariya sandstone formations at 9956 ft, and 10205 ft. The plan trajectory was vertical profile and due to wellbore instability, the well was side-tracked. The two proposed profiles are modelled and selected for this well based on statistical study analysis of actual well data. Based on the data, it was found that the percentage of hole problems lost time is higher with a maximum of 55% and NPT is the major problem facing drilling processes in zone of well 3. The selected S-shape trajectory results in KOP= 8400 ft, INC= 22.604 degrees, the hold section begins with a constant inclination at MD= 9200 ft, TVD= 9178.92 ft, and HD= 157.6 up to MD= 10100 ft, TVD= 10102.1 ft, and HD= 541.965 ft. Drop section starts at MD= 10262 ft, TVD= 10158.98 ft, and the target is hit at MD= 11052 ft, and TVD= 10929 ft. Using MCM, the optimum survey trajectory for the S-type well profile results at MD= 11052 ft, and azimuth= 43.827 degrees. For the numerical design and optimization of the double build horizontal well, 3 different algorithms are programmed with different input parameters to define a set of optimal solutions. The algorithms are PSO1, PSO2, and PSO3. However, the performance of PSO2 is significantly better than PSO1 and PSO3 based on the statistical test applied using the Wilcoxon ranksum test. Therefore, the parameters of PSO2 are the optimal solutions chosen for the well under study (well-3). The result of the optimized parameters is; KOP1= 7182 ft, KOP2= 8488 ft, hold angle in degrees= 20.4, build-up rate of upper section= 2.9 deg/100ft, and build-up rate for the lower section= 2.5 deg/100ft.