To put it simply, work is equal to force multiplied by distance. However, you could also think about force and direction of motion as vectors. Vectors have both magnitude and direction. When vectors are used, then work is equal to the force vector dotted with the distance vector. To calculate the dot product between two vectors, it is the magnitude of one vector multiplied by the magnitude of the other and also multiplied by the cosine of the angle between the force and distance vectors.
To give an example, if you push really hard against something and it doesn’t move anywhere then no work was performed on the object intended to be moved. All of the energy is consumed by other processes, such as your muscles.
Hopefully this helps!