This paper studies unmanned aerial vehicle (UAV)-aided nonorthogonal multiple access (NOMA)-based mobile-edge computing (MEC) in Internet of Things (IoT) systems in which the UAV acts as relay (UR). Specifically, we consider a scenario with two cluster IoT devices (IDs) (i.e., a high-priority cluster IA and a low-priority cluster IB) with limited resources, so these IDs cannot compute their tasks and must offload them to a base station (BS) through UR. We propose a protocol named time switching -radio frequency (RF) energy harvesting (EH) UR NOMA (REUN) (TS-REUN), which is divided into 5 phases. By applying the TS-REUN protocol, the IDs in two clusters and UR harvest RF energy from the broadcasting signal of the power beacons (PB). Then, the IDs offload their tasks to the MEC server located at the BS. After server processing, the IDs receive the calculation results from the BS via UR. The effects of both imperfect channel state information (ICSI) and imperfect successive interference cancellation (ISIC) on the REUN-based MEC (REUN-MEC) are taken into account. To evaluate the performance of the system, we derive closed-form expressions for the successful computation probability (SCP) and energy consumption probability (ECP) under the Nakagami-m fading channel. Moreover, we propose an optimization problem formulation that aims to maximize SCP by optimizing the position and height of UR and the time switching ratio (TSR). The problem is addressed by employing an algorithm based on particle swarm optimization (PSO). In addition, the Monte Carlo simulation results are presented to confirm the accuracy of our analysis based on system performance simulations with various system parameters, such as the number of antennas at the BS, the number of IDs in each cluster, TSR, and the position and height of UR.INDEX TERMS Internet of Things, unmanned aerial vehicles, energy harvesting, nonorthogonal multiple access, mobile-edge computing.