This work presents the optimal reliability of a smart grid using Particle Swarm Optimization (PSO) and the Monte Carlo analysis. In the electrical grid, reliability defines the permanent supply of energy and the satisfaction of customers. In this paper, the reliability of a smart grid is examined in the baseline scenario consisted of no faults and the scenarios consisted of faults both in the presence or absence of Distributed Generation units (DGs) using co-simulations. The study determines the optimal allocation and size of the DGs during faulty scenarios which was carried out using PSO. This work proposes an OpenDSS-OMNet++ platform applied in the electrical grid and communication network to achieve the smart distribution grid. The aim consists to assess the capacity of the system according to various possibilities and the automation level of the network. The 13-node IEEE system is implemented using the method and the proposed framework. In case of fault, the voltage drop is 45%, the SAIFI is 40 and with optimal allocation of distributed generation, the voltage drop moves to 2.3%, the SAIFI is 0.55. The energy losses go from 5232686.67 kWh/year to 211076.68 kWh/year, i.e. a difference of nearly 5021609.99 kWh/year. The final results indicate that our algorithm is efficient and reliable and can help companies of energy for future reliability trials and the progression of distributed generation in smart distribution grid.