In Japanese, ~koto wo suru ~ことをする (koto こと, marked by wo を, plus suru する) means "to do something that is X" or "to do an X thing," what sort of thing we're doing depends on the adjective or relative clause qualifying koto. It effectively lets you create suru-verbs out of random phrases describing acts so you can conjugate the description like a verb. When the description already ends in a verb to begin with, sometimes the phrase ~koto wo suru just makes the sentence longer.
- {warui} koto wo suru
悪いことをする
To do something [that] {is bad}.
To do a {bad} thing. - sonna koto shitara
そんなことしたら
If [you] do something like that... - {fudan shinai} koto wo suru
普段しないことをする
To do something [that] {[you] normally don't do}.
To do things [you] {normally don't}. - {mahou wo tsukau} koto ga dekiru
魔法を使うことができる
To be able to do the thing [that is] {to use magic}.
To be able to {use magic}.- mahou ga tsukaeru
魔法が使える
To be able to use magic.
- mahou ga tsukaeru
The phrase ~koto ga dekiru ~ことができる is the irregular potential form of ~koto wo suru. The phrase ~koto wo itashimasu ~ことをいたします is a humble speech (kenjougo 謙譲語) variant, while ~koto wo nasaru ~ことをなさる is a honorific speech (sonkeigo 尊敬語) variant. The phrases ~koto suru ~ことする, ~koto dekiru ~ことできる, ~koto itashimasu ~こといたします, and ~koto nasaru ~ことなさる are null-marked (φ).